<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"  media="all">
    <script th:src="@{/jquery/jquery-3.3.1.js}" type="text/javascript"></script>
    <script th:src="@{/layui/layui.js}" type="text/javascript"></script>
    <script th:src="@{/common/layuiload.js}" type="text/javascript"></script>
    <title>新增</title>
    <style>
    /*css*/
    </style>

</head>
<body style="margin-left:20px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>新增</legend>
</fieldset>
<form id="comitform" class="layui-form" th:action="@{/roles/insertDo}" method="post">
    <input type="hidden" id="uid" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">角色名字</label>
        <div class="layui-input-block">
            <input type="text" name="name" value="" lay-verify="title" autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">描述</label>
        <div class="layui-input-block">
            <input type="text" name="desc" value="" lay-verify="title" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属小组</label>
        <div class="layui-input-block" >
            <select  lay-filter="team">
                <option value=""></option>
                <option th:each="t:${team}" th:value="${t.id}+','+${t.team}" th:text="${t.team}"></option>
            </select>
        </div>
    </div>
    <input type="hidden" value="" name="pid" id="pid">
    <input type="hidden" value="" name="team" id="team">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" type="button" lay-filter="demo1" onclick="comitform()">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script th:inline="javascript">
    layui.use('form', function() {
        var form = layui.form;
        form.on('select(team)', function (data) {
            setpid(data.value);
        });
    });
    //js
    function setpid(val) {
        var ss =val.split(",");
        $("#pid").val(ss[0]);
        $("#team").val(ss[1]);
    }

    function comitform(){
        var pid=$("#pid").val();
        var team=$("#team").val();
        if(pid!="" && team!=""){
            $("#comitform").submit();
        }else{
            alert("未填写完整!");
        }
    }
</script>
</html>